﻿#ifndef THREADFORCURL_H
#define THREADFORCURL_H

#include <QJsonObject>
#include <QTimer>
#include <QThread>
#include <QMutex>
#include <QWaitCondition>
#include <QThreadPool>
#include <QObject>
#include <QRunnable>
#include <QString>
#include <QProcess>

namespace Curl {
class CurlTask : public QObject, public QRunnable
{
    Q_OBJECT
public:
    CurlTask(QJsonObject);
    ~CurlTask();

    void run();

protected:


public slots:
    void on_readoutput();
    void on_readerror();
    void on_finished(int exitCode,QProcess::ExitStatus exitStatus);
    void on_errorOccurred(QProcess::ProcessError error);

signals:
    void someData(QJsonObject);

private:
    QJsonObject m_all;

};
class DataWorker;
class Controller : public QObject
{
    Q_OBJECT

public:
    Controller();

    ~Controller() {
        if(pool)
            delete pool;
    }

    void addNewTask(QJsonObject);
signals:
//    void sendData(QJsonObject);
//    void startInit();
    void getReturn(QJsonObject);

public slots:
    void someData(QJsonObject);

private:
    QThreadPool *pool;
};
}
#endif // THREADFORCURL_H
